/**
 * 
 */
package org.gigi.security.domain;

import java.io.Serializable;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * 用户组与用户关联实体。
 *
 * @author Eugene Wang 2011-9-14
 * @see
 */
@Entity
@Table(name = "sec_rl_group_user")
public class GroupUser implements Serializable {
	private static final long serialVersionUID = 1L;
	@EmbeddedId
	private GroupUserPk id;
	@ManyToOne
	@JoinColumn(name ="group_id", insertable=false, updatable=false)
	private Group group;
	@ManyToOne
	@JoinColumn(name = "username", insertable=false, updatable=false)
	private User  user;

	/**
	 * 默认构造函数。
	 */
	public GroupUser() {
	}

	/**
	 * 构造函数。
	 * @param group
	 * @param user
	 */
	public GroupUser(Group group, User user) {
		GroupUserPk pk = new GroupUserPk();
		pk.setGroupId(group.getId());
		pk.setUsername(user.getUsername());
		this.id = pk;
		this.group = group;
		this.user = user;
	}
	public GroupUserPk getId() {
		return id;
	}
	public void setId(GroupUserPk id) {
		this.id = id;
	}
	public Group getGroup() {
		return group;
	}
	public void setGroup(Group group) {
		this.group = group;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
}
